<?php
include_once("connexion.php");
if( isset($_POST["ok"])){
	$_SESSION['login'] = $_POST["nom"];
	$mdp = sha1($_POST["pass"]);
	
	$query = 'SELECT * FROM User WHERE login="'.$_POST['nom'].'"';
	$resultat = mysqli_query($bdd, $query);
	$user = mysqli_fetch_array($resultat);
	
	if($mdp == $user["Password"] && $user["id_spe"] == 0){
	     $_SESSION['co'] = "30";
	     $_SESSION['id'] = $user['Id'];
	     $_SESSION['login'] = $user['login'];
	     echo "Vous êtes connecté ".$_SESSION['login'];
	     
		}
	else if($mdp == $user["mdp"] && $user["id_spe"] == 1){
	     $_SESSION['co'] = "40";
	     $_SESSION['id'] = $user['Id'];
	     $_SESSION['login'] = $user['login'];
	     echo "Vous êtes connecté ".$_SESSION['login'];
	     
		}
	else if($mdp =! $user["mdp"]){
		echo "Mot de passe ou login invalide";
		}
	
	
}

?>

